package com.eos.control.action.emp;

import com.eos.business.service.SysUserBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.common.tool.DataCacheUtil;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysUser;

public class DeleteEmpAction extends AbstractBaseAction {
	private static final long serialVersionUID = -3706648245758146735L;
	private Integer sysUserId;
	
	public void setSysUserId(Integer sysUserId) {
		this.sysUserId = sysUserId;
	}

	@Override
	public String execute() {
		 try{
			 if(null == sysUserId || sysUserId.intValue() <=0){
				 statusCode = "300";
				 message = "参数错误,删除用户失败!";
			 }else{
				 SysUser user = new SysUser();
				 user.setId(sysUserId);
				 user.setDealFlag(ConstantTool.DEAL_FLAG_FAIL);
				 SysUserBusinessService sbs = new SysUserBusinessService();
				 String flag = sbs.update(user);
				 if("SUCCESS".equals(flag)){
					 statusCode = "200";
					 message = "删除用户成功!";
					 DataCacheUtil.clearSysUserMap();
				 }else{
					 statusCode = "300";
					 message = "系统繁忙, 删除用户失败!";
				 }
			 }
		 }catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常,删除用户失败!";
		}
		 return SUCCESS;
	}
}
